package com.dg11185.nearshop.net.request;

import com.dg11185.libs.utils.MD5.MD5Utils;
import com.dg11185.nearshop.app.Constants;
import com.dg11185.nearshop.net.HttpCacheRequest;
import com.dg11185.nearshop.net.response.GetAreaListResponse;

/**
 * @author : daibo
 * @version : 2014-5-15 下午9:34:32
 * @see :
 */
public class GetAreaListRequest extends HttpCacheRequest<GetAreaListResponse> {

    public final static String PARENT_ID = "parentId";
    public final static String CHSH_TOKEN = "chshToken";
    public final static String CHSH_SIGN = "chshSign";

    public GetAreaListRequest(String parentId) {
        super(Constants.ADDRESS, Constants.getAreaList);
        addParam("parentId", parentId);
        addParam("chshToken", Constants.TOKEN);
        addParam("chshSign", MD5Utils.getMD5Str(getParams(), Constants.MD5_key));
        setWifiTimeSpan(30*24*3600*1000);
        set_3GTimeSpan(30*24*3600*1000);
    }

    public GetAreaListRequest encryption() {
        addParam("chshSign", MD5Utils.getMD5Str(getParams(), Constants.MD5_key));
        return this;
    }

    @Override
    protected GetAreaListResponse parseJson(String response) throws Exception {
        GetAreaListResponse r = new GetAreaListResponse();
        r.parseJson(response);
        return r;
    }
}
